import Vue from 'vue';
import API from "../requestApi/taskApi";
import { get, post } from "../requestApi/request";
const task = {
    // 管理员登录
    adminLoginFun: function adminLoginFun(params) {
        return Vue.http.post(API.adminLogin, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 修改密码
    adminSettingFun: function adminSettingFun(params) {
        return Vue.http.post(API.adminSetting, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 业务主删除
    providerDeleteFun: function providerDeleteFun(params) {
        return Vue.http.post(API.providerDelete, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 业务主详情
    providerInfoFun: function providerInfoFun(params) {
        let ip = `${API.providerInfo}?providerId=${params.providerId}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 业务主添加
    providerInsertFun: function providerInsertFun(params) {
        return Vue.http.post(API.providerInsert, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 业务主列表
    providerListFun: function providerListFun(params) {
        let ip = `${API.providerList}?page=${params.page}&size=${params.size}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 应用删除
    appDeleteFun: function appDeleteFun(params) {
        let ip = `${API.appDelete}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 应用查询
    appInfoFun: function appInfoFun(params) {
        let ip = `${API.appInfo}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 应用添加
    appInsertFun: function appInsertFun(params) {
        let ip = `${API.appInsert}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 应用列表
    appListFun: function appListFun(params) {
        let ip = `${API.appList}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 活动信息
    promotionInfoFun: function promotionInfoFun(params) {
        let ip = `${API.promotionInfo}?promotionId=${params.promotionId}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 活动列表查询
    promotionListFun: function promotionListFun(params) {
        let ip = `${API.promotionList}?page=${params.page}&size=${params.size}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 活动参与人
    promotionParticipantsFun: function promotionParticipantsFun(params) {
        let ip = `${API.promotionParticipants}?promotionId=${params.promotionId}&page=${params.page}&size=${params.size}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 保存活动
    promotionSaveFun: function promotionSaveFun(params) {
        return Vue.http.post(API.promotionSave, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 删除活动
    promotionDeleteFun: function promotionDeleteFun(params) {
        return Vue.http.post(API.promotionDelete, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 活动更新审核状态
    promotionUpdateApprovalFun: function promotionUpdateApprovalFun(params) {
        return Vue.http.post(API.promotionUpdateApproval, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 新建消息
    webMessageCreateAndSendFun: function webMessageCreateAndSendFun(params) {
        return Vue.http.post(API.webMessageCreateAndSend, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 消息详情
    webMessageDetailFun: function webMessageDetailFun(params) {
        let ip = `${API.webMessageDetail}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 消息列表
    webMessageListFun: function webMessageListFun(params) {
        let ip = `${API.webMessageList}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //管理员删除
    adminDeleteFun: function adminDeleteFun(params) {
        return Vue.http.post(API.adminDelete, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 管理员查询
    adminInfoFun: function adminInfoFun(params) {
        let ip = `${API.adminInfo}?code=${params.code}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //管理员添加
    adminInsertFun: function adminInsertFun(params) {
        return Vue.http.post(API.adminInsert, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 管理员列表
    adminListFun: function adminListFun(params) {
        let ip = `${API.adminList}?page=${params.page}&size=${params.size}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //重置密码
    adminResettingFun: function adminResettingFun(params) {
        return Vue.http.post(API.adminResetting, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //角色删除
    adminRoleDeleteFun: function adminRoleDeleteFun(params) {
        return Vue.http.post(API.adminRoleDelete, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 角色查询
    adminRoleInfoFun: function adminRoleInfoFun(params) {
        let ip = `${API.adminRoleInfo}?code=${params.code}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //角色添加
    adminRoleInsertFun: function adminRoleInsertFun(params) {
        return Vue.http.post(API.adminRoleInsert, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 角色列表
    adminRoleListFun: function adminRoleListFun(params) {
        let ip = `${API.adminRoleList}?page=${params.page}&size=${params.size}`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //添加奖品
    webAwardFun: function webAwardFun(params) {
        return Vue.http.post(API.webAward, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    // 分页获取奖品
    webAwardPageFun: function webAwardPageFun(params) {
        let ip = `${API.webAwardPage}?memberId=${params.memberId}&taskIds=${
            params.taskIds
            }`;
        return Vue.http.get(ip, {}).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
    //更新奖品
    webAwardUpdateFun: function webAwardUpdateFun(params) {
        return Vue.http.post(API.webAwardUpdate, params).then(response => {
            if (response.status === 200) {
                return Promise.resolve(response.body);
            } else {
                return Promise.reject(response.data);
            }
        });
    },
}
export default task
